package _06_动态规划;

public class _62_不同路径 {

    public static void main(String[] args) {
        _62_不同路径 v = new _62_不同路径();
        System.out.println(v.uniquePaths(3, 7));
    }

    public int uniquePaths(int rows, int cols) {
        // 定义dp数组, 第row行第col列的最小路劲
        int[][] dp = new int[rows][cols];
        // 初始化dp数组
        dp[0][0] = 1;
        for (int col = 1; col < cols; col++) {
            dp[0][col] = 1;
        }
        for (int row = 1; row < rows; row++) {
            dp[row][0] = 1;
        }
        for (int row = 1; row < rows; row++) {
            for (int col = 1; col < cols; col++) {
                dp[row][col] = dp[row - 1][col] + dp[row][col - 1];
            }
        }
        return dp[rows - 1][cols - 1];
    }

}
